package com.woniuxy.controller;

import com.woniuxy.Exception.serviceException;
import com.woniuxy.entity.Doctor;
import com.woniuxy.entity.Nurse;
import com.woniuxy.entity.PageBean;
import com.woniuxy.entity.ResponseResult;
import com.woniuxy.service.NurseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
public class NurseController {
@Autowired
    NurseService nurseService;
  @PostMapping("/nurse/{pageIndex}/{pageSize}")
public ResponseResult<PageBean<Nurse>>getAllNurse(@RequestBody Nurse nurse,
                                                  @PathVariable("pageIndex")int pageIndex,
                                                  @PathVariable("pageSize")int pageSize) {

      ResponseResult<PageBean<Nurse>> responseResult;
      try {
          PageBean<Nurse> pageBean = nurseService.getAllNurse(nurse, pageIndex, pageSize);
          responseResult = new ResponseResult<>(200, "ok", pageBean);

          return responseResult;
      } catch (serviceException e) {
          responseResult = new ResponseResult<>(500, e.getMessage(), null);
          return responseResult;
      }
  }


@PostMapping("/nurse")
    public  void  addNurse(@RequestBody Nurse nurse){
      nurseService.addNurse(nurse);




}

@PutMapping("/nurse")
    public  void  upNurse (@RequestBody Nurse nurse){
      nurseService.upNurse(nurse);


}

@DeleteMapping("/nurse")
    public  void  removeNurse(int nurseId){

      nurseService.removeNurse(nurseId);

}


}
